<template>
	<view class="container">
		<div></div>
		<view>
			<u--form labelPosition="left" :model="form" ref="form1" labelWidth='120px' :labelStyle='labelStyle'>
				<view class="title">
					基础信息
				</view>
				<view class="box">
					<u-form-item label="作业名称" borderBottom>
						<u--input v-model="form.name" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<u-form-item label="作业区域" borderBottom>
						<u--input v-model="form.zyqyName" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<u-form-item label="监护人" borderBottom>
						<u--input v-model="form.jhrName" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<u-form-item :label="item.name" borderBottom v-for="(item,index) in this.form.resultObject" :key="index">
						<u--input v-model="item.value" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<!-- <Form :formList="formList" :ysrName="form.ysrName" :jhrName="form.jhrName" :name="form.name" :zyqy="form.zyqyName" ref="baseForm">
					</Form> -->
				<!-- 	<u-form-item label="作业申请单位" borderBottom>
						<u--input v-model="form.作业申请单位" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<u-form-item label="作业单位" borderBottom>
						<u--input v-model="form.作业单位" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<u-form-item label="作业开始时间" borderBottom>
						<u--input v-model="form.作业开始时间" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<u-form-item label="作业结束时间" borderBottom>
						<u--input v-model="form.作业结束时间" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<u-form-item label="作业内容" borderBottom>
						<u--textarea v-model="form.作业内容" disabled disabledColor='#fff' confirmType="next"></u--textarea>
					</u-form-item>
					<u-form-item label="动火地点" borderBottom>
						<u--input v-model="form.动火地点" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<u-form-item label="动火作业级别" borderBottom>
						<u--input v-model="form.动火作业级别" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<u-form-item label="动火方式">
						<u--textarea v-model="form.动火方式" disabled disabledColor='#fff' confirmType="next"></u--textarea>
					</u-form-item> -->
					
				</view>
				<view class="title">
					关联特殊作业
				</view>
				<view class="box">
					<u-form-item label="关联特殊作业">
						<u--input v-model="form.关联的其他特殊作业" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
				</view>
				<view class="title">
					气体检测
				</view>
				<view class="box">
					<u-form-item label="取样分析时间" borderBottom>
						<u--input v-model="form.qtjc.qyfxsj" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<u-form-item label="代表性气体" borderBottom>
						<u--input v-model="form.qtjc.dbxqt" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<u-form-item label="有毒气体" borderBottom>
						<u--input v-model="form.qtjc.ydqt" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<u-form-item label="可燃气体" borderBottom>
						<u--input v-model="form.qtjc.krqt" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<u-form-item label="氧含量" borderBottom>
						<u--input v-model="form.qtjc.yhl" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<!-- <u-form-item label="分析结果" borderBottom>
						<u--input v-model="form.分析结果" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item> -->
					<u-form-item label="分析人">
						<u--input v-model="form.qtjc.fxr" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
				</view>
				<!-- <view class="title">
					危害辨识-安全措施
				</view>
				<view class="box">
					<u-form-item label="危害辨识" borderBottom>
						<u--input v-model="form.text" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<u-form-item label="安全措施" borderBottom>
						<u--input v-model="form.text" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
					<u-form-item label="个人用品防护" borderBottom>
						<u--input v-model="form.text" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>

				</view> -->
				<view class="title">
					作业审批人员
				</view>
				<view class="box">
					<u-form-item :label="item.rypz" borderBottom v-for="(item,index) in this.form.tzypshrjlxxes"
						:key="index">
						<u--input v-model="item.ry" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
				</view>
				<view class="title">
					验收
				</view>
				<view class="box">
					<u-form-item label="验收人" borderBottom>
						<u--input v-model="form.ysrName" disabled disabledColor='#fff' border="none"></u--input>
					</u-form-item>
				</view>
			</u--form>
			<view class="" style="display: flex;">
				<!-- <u-button type="" :plain="true" text="驳回" class='but' @tap='goreasonforRejection'></u-button> -->
				<u-button type="primary" text="我已阅读,下一步" @click="submit" class='but'></u-button>
			</view>
		</view>
	</view>
</template>

<script>
	import Form from '@/pages/Components/formMessage/formMessage.vue'
	import {
		workAcceptanceDetailsAPI,
		workSubmitAPI
	} from '@/api/api.js'
	import {
		idGetDept
	} from '@/api/public.js'
	export default {
		components:{
			Form
		},
		data() {
			return {
				id: '',
				showSex: false,
				labelStyle: {
					color: '#666'
				},
				form: {
					text: '',
					basicInformation: [],
				},

			};
		},
		onLoad(option) {
			this.id = option.id
			this.getDetails()
		},
		// mounted() {
			
		// 	// this.workSubmit()
		// },
		methods: {
			// workSubmit(){
			//   workSubmitAPI(this.id,4).then((r)=>{
			//     console.log(10086,r)
			//   })
			// },
			getDetails() {
				let a = null
				let resultObject = []
				workAcceptanceDetailsAPI(this.id, 4).then((r) => {
					a = JSON.parse(r.data.jsonwbnr)
					// for (const key of a) {
					// 	b.push({
					// 		[key.name]: key.value
					// 	})
					// }
					for (const key of a) {
						if(typeof key.value === 'string'&&  key.name!=="作业名称"&&key.name!=="作业区域"){
							resultObject.push(key)
						}
					}
					resultObject.forEach((e)=>{
						if(e.name.search("单位") !== -1){
								idGetDept(e.value).then((r)=>{
									e.value=r.data.deptName
								})
						}
					})
					// let resultObject = b.reduce(function(result, currentObject) {
					// 	for (let key in currentObject) {
					// 		if (currentObject.hasOwnProperty(key)) {
					// 			result[key] = currentObject[key];
					// 		}
					// 	}
					// 	return result;
					// }, {});
					this.form = {
						resultObject,
						...r.data
					}
					// this.form.resultObject = b;
					// idGetDept(this.form.作业申请单位).then((r) => {
					// 	this.form.作业申请单位=r.data.deptName
					// 	idGetDept(this.form.作业单位).then((r)=>{
					// 		this.form.作业单位=r.data.deptName
					// 		console.log(this.form);
					// 	})
					// })
					console.log(5846545,this.form);
				})
			},
			submit() {
				uni.navigateTo({
					url: `../measuress/measuress?form=${JSON.stringify(this.form)}`
				})
			},
			// 驳回
			goreasonforRejection() {
				uni.navigateTo({
					url: '../reasonforRejection/reasonforRejection'
				})
			}
		}
	}
</script>

<style lang="scss">
	.container {
		padding: 0 24rpx;
		background-color: #f6f6f6;

		.title {
			font-size: 28rpx;
			font-weight: 500;
			color: #999999;
			line-height: 44rpx;
			padding: 20rpx 48rpx;
		}

		.box {
			padding: 0rpx 48rpx;
			background-color: #fff;
			border-radius: 20rpx;
		}
	}

	.but {
		margin: 30rpx 0;
	}
</style>
